
(in-package #:lispbuilder-sdl-cffi) 

(cffi:defcenum SDL-Key
	(:SDL-KEY-UNKNOWN 0)
	(:SDL-KEY-FIRST 0)
	(:SDL-KEY-BACKSPACE 8)
	(:SDL-KEY-TAB 9)
	(:SDL-KEY-CLEAR 12)
	(:SDL-KEY-RETURN 13)
	(:SDL-KEY-PAUSE 19)
	(:SDL-KEY-ESCAPE 27)
	(:SDL-KEY-SPACE 32)
	(:SDL-KEY-EXCLAIM 33)
	(:SDL-KEY-QUOTEDBL 34)
	(:SDL-KEY-HASH 35)
	(:SDL-KEY-DOLLAR 36)
	(:SDL-KEY-AMPERSAND 38)
	(:SDL-KEY-QUOTE 39)
	(:SDL-KEY-LEFTPAREN 40)
	(:SDL-KEY-RIGHTPAREN 41)
	(:SDL-KEY-ASTERISK 42)
	(:SDL-KEY-PLUS 43)
	(:SDL-KEY-COMMA 44)
	(:SDL-KEY-MINUS 45)
	(:SDL-KEY-PERIOD 46)
	(:SDL-KEY-SLASH 47)
	(:SDL-KEY-0 48)
	(:SDL-KEY-1 49)
	(:SDL-KEY-2 50)
	(:SDL-KEY-3 51)
	(:SDL-KEY-4 52)
	(:SDL-KEY-5 53)
	(:SDL-KEY-6 54)
	(:SDL-KEY-7 55)
	(:SDL-KEY-8 56)
	(:SDL-KEY-9 57)
	(:SDL-KEY-COLON 58)
	(:SDL-KEY-SEMICOLON 59)
	(:SDL-KEY-LESS 60)
	(:SDL-KEY-EQUALS 61)
	(:SDL-KEY-GREATER 62)
	(:SDL-KEY-QUESTION 63)
	(:SDL-KEY-AT 64)
	(:SDL-KEY-LEFTBRACKET 91)
	(:SDL-KEY-BACKSLASH 92)
	(:SDL-KEY-RIGHTBRACKET 93)
	(:SDL-KEY-CARET 94)
	(:SDL-KEY-UNDERSCORE 95)
	(:SDL-KEY-BACKQUOTE 96)
	(:SDL-KEY-a 97)
	(:SDL-KEY-b 98)
	(:SDL-KEY-c 99)
	(:SDL-KEY-d 100)
	(:SDL-KEY-e 101)
	(:SDL-KEY-f 102)
	(:SDL-KEY-g 103)
	(:SDL-KEY-h 104)
	(:SDL-KEY-i 105)
	(:SDL-KEY-j 106)
	(:SDL-KEY-k 107)
	(:SDL-KEY-l 108)
	(:SDL-KEY-m 109)
	(:SDL-KEY-n 110)
	(:SDL-KEY-o 111)
	(:SDL-KEY-p 112)
	(:SDL-KEY-q 113)
	(:SDL-KEY-r 114)
	(:SDL-KEY-s 115)
	(:SDL-KEY-t 116)
	(:SDL-KEY-u 117)
	(:SDL-KEY-v 118)
	(:SDL-KEY-w 119)
	(:SDL-KEY-x 120)
	(:SDL-KEY-y 121)
	(:SDL-KEY-z 122)
	(:SDL-KEY-DELETE 127)
	(:SDL-KEY-WORLD-0 160)
	(:SDL-KEY-WORLD-1 161)
	(:SDL-KEY-WORLD-2 162)
	(:SDL-KEY-WORLD-3 163)
	(:SDL-KEY-WORLD-4 164)
	(:SDL-KEY-WORLD-5 165)
	(:SDL-KEY-WORLD-6 166)
	(:SDL-KEY-WORLD-7 167)
	(:SDL-KEY-WORLD-8 168)
	(:SDL-KEY-WORLD-9 169)
	(:SDL-KEY-WORLD-10 170)
	(:SDL-KEY-WORLD-11 171)
	(:SDL-KEY-WORLD-12 172)
	(:SDL-KEY-WORLD-13 173)
	(:SDL-KEY-WORLD-14 174)
	(:SDL-KEY-WORLD-15 175)
	(:SDL-KEY-WORLD-16 176)
	(:SDL-KEY-WORLD-17 177)
	(:SDL-KEY-WORLD-18 178)
	(:SDL-KEY-WORLD-19 179)
	(:SDL-KEY-WORLD-20 180)
	(:SDL-KEY-WORLD-21 181)
	(:SDL-KEY-WORLD-22 182)
	(:SDL-KEY-WORLD-23 183)
	(:SDL-KEY-WORLD-24 184)
	(:SDL-KEY-WORLD-25 185)
	(:SDL-KEY-WORLD-26 186)
	(:SDL-KEY-WORLD-27 187)
	(:SDL-KEY-WORLD-28 188)
	(:SDL-KEY-WORLD-29 189)
	(:SDL-KEY-WORLD-30 190)
	(:SDL-KEY-WORLD-31 191)
	(:SDL-KEY-WORLD-32 192)
	(:SDL-KEY-WORLD-33 193)
	(:SDL-KEY-WORLD-34 194)
	(:SDL-KEY-WORLD-35 195)
	(:SDL-KEY-WORLD-36 196)
	(:SDL-KEY-WORLD-37 197)
	(:SDL-KEY-WORLD-38 198)
	(:SDL-KEY-WORLD-39 199)
	(:SDL-KEY-WORLD-40 200)
	(:SDL-KEY-WORLD-41 201)
	(:SDL-KEY-WORLD-42 202)
	(:SDL-KEY-WORLD-43 203)
	(:SDL-KEY-WORLD-44 204)
	(:SDL-KEY-WORLD-45 205)
	(:SDL-KEY-WORLD-46 206)
	(:SDL-KEY-WORLD-47 207)
	(:SDL-KEY-WORLD-48 208)
	(:SDL-KEY-WORLD-49 209)
	(:SDL-KEY-WORLD-50 210)
	(:SDL-KEY-WORLD-51 211)
	(:SDL-KEY-WORLD-52 212)
	(:SDL-KEY-WORLD-53 213)
	(:SDL-KEY-WORLD-54 214)
	(:SDL-KEY-WORLD-55 215)
	(:SDL-KEY-WORLD-56 216)
	(:SDL-KEY-WORLD-57 217)
	(:SDL-KEY-WORLD-58 218)
	(:SDL-KEY-WORLD-59 219)
	(:SDL-KEY-WORLD-60 220)
	(:SDL-KEY-WORLD-61 221)
	(:SDL-KEY-WORLD-62 222)
	(:SDL-KEY-WORLD-63 223)
	(:SDL-KEY-WORLD-64 224)
	(:SDL-KEY-WORLD-65 225)
	(:SDL-KEY-WORLD-66 226)
	(:SDL-KEY-WORLD-67 227)
	(:SDL-KEY-WORLD-68 228)
	(:SDL-KEY-WORLD-69 229)
	(:SDL-KEY-WORLD-70 230)
	(:SDL-KEY-WORLD-71 231)
	(:SDL-KEY-WORLD-72 232)
	(:SDL-KEY-WORLD-73 233)
	(:SDL-KEY-WORLD-74 234)
	(:SDL-KEY-WORLD-75 235)
	(:SDL-KEY-WORLD-76 236)
	(:SDL-KEY-WORLD-77 237)
	(:SDL-KEY-WORLD-78 238)
	(:SDL-KEY-WORLD-79 239)
	(:SDL-KEY-WORLD-80 240)
	(:SDL-KEY-WORLD-81 241)
	(:SDL-KEY-WORLD-82 242)
	(:SDL-KEY-WORLD-83 243)
	(:SDL-KEY-WORLD-84 244)
	(:SDL-KEY-WORLD-85 245)
	(:SDL-KEY-WORLD-86 246)
	(:SDL-KEY-WORLD-87 247)
	(:SDL-KEY-WORLD-88 248)
	(:SDL-KEY-WORLD-89 249)
	(:SDL-KEY-WORLD-90 250)
	(:SDL-KEY-WORLD-91 251)
	(:SDL-KEY-WORLD-92 252)
	(:SDL-KEY-WORLD-93 253)
	(:SDL-KEY-WORLD-94 254)
	(:SDL-KEY-WORLD-95 255)
	(:SDL-KEY-KP0 256)
	(:SDL-KEY-KP1 257)
	(:SDL-KEY-KP2 258)
	(:SDL-KEY-KP3 259)
	(:SDL-KEY-KP4 260)
	(:SDL-KEY-KP5 261)
	(:SDL-KEY-KP6 262)
	(:SDL-KEY-KP7 263)
	(:SDL-KEY-KP8 264)
	(:SDL-KEY-KP9 265)
	(:SDL-KEY-KP-PERIOD 266)
	(:SDL-KEY-KP-DIVIDE 267)
	(:SDL-KEY-KP-MULTIPLY 268)
	(:SDL-KEY-KP-MINUS 269)
	(:SDL-KEY-KP-PLUS 270)
	(:SDL-KEY-KP-ENTER 271)
	(:SDL-KEY-KP-EQUALS 272)
	(:SDL-KEY-UP 273)
	(:SDL-KEY-DOWN 274)
	(:SDL-KEY-RIGHT 275)
	(:SDL-KEY-LEFT 276)
	(:SDL-KEY-INSERT 277)
	(:SDL-KEY-HOME 278)
	(:SDL-KEY-END 279)
	(:SDL-KEY-PAGEUP 280)
	(:SDL-KEY-PAGEDOWN 281)
	(:SDL-KEY-F1 282)
	(:SDL-KEY-F2 283)
	(:SDL-KEY-F3 284)
	(:SDL-KEY-F4 285)
	(:SDL-KEY-F5 286)
	(:SDL-KEY-F6 287)
	(:SDL-KEY-F7 288)
	(:SDL-KEY-F8 289)
	(:SDL-KEY-F9 290)
	(:SDL-KEY-F10 291)
	(:SDL-KEY-F11 292)
	(:SDL-KEY-F12 293)
	(:SDL-KEY-F13 294)
	(:SDL-KEY-F14 295)
	(:SDL-KEY-F15 296)
	(:SDL-KEY-NUMLOCK 300)
	(:SDL-KEY-CAPSLOCK 301)
	(:SDL-KEY-SCROLLOCK 302)
	(:SDL-KEY-RSHIFT 303)
	(:SDL-KEY-LSHIFT 304)
	(:SDL-KEY-RCTRL 305)
	(:SDL-KEY-LCTRL 306)
	(:SDL-KEY-RALT 307)
	(:SDL-KEY-LALT 308)
	(:SDL-KEY-RMETA 309)
	(:SDL-KEY-LMETA 310)
	(:SDL-KEY-LSUPER 311)
	(:SDL-KEY-RSUPER 312)
	(:SDL-KEY-MODE 313)
	(:SDL-KEY-COMPOSE 314)
	(:SDL-KEY-HELP 315)
	(:SDL-KEY-PRINT 316)
	(:SDL-KEY-SYSREQ 317)
	(:SDL-KEY-BREAK 318)
	(:SDL-KEY-MENU 319)
	(:SDL-KEY-POWER 320)
	(:SDL-KEY-EURO 321)
	(:SDL-KEY-UNDO 322)
	:SDL-KEY-LAST)

(cffi:defcenum SDL-Mod
	(:SDL-KEY-MOD-NONE #x0000)
	(:SDL-KEY-MOD-LSHIFT #x0001)
	(:SDL-KEY-MOD-RSHIFT #x0002)
	(:SDL-KEY-MOD-LCTRL #x0040)
	(:SDL-KEY-MOD-RCTRL #x0080)
	(:SDL-KEY-MOD-LALT #x0100)
	(:SDL-KEY-MOD-RALT #x0200)
	(:SDL-KEY-MOD-LMETA #x0400)
	(:SDL-KEY-MOD-RMETA #x0800)
	(:SDL-KEY-MOD-NUM #x1000)
	(:SDL-KEY-MOD-CAPS #x2000)
	(:SDL-KEY-MOD-MODE #x4000)
	(:SDL-KEY-MOD-RESERVED #x8000))

(cffi:defcstruct SDL-key-sym
	(scancode :unsigned-char)
	(sym SDL-Key)
	(mod :int) ;SDL-Mod
	(unicode :unsigned-short))

(cl:defconstant SDL-ALL-HOTKEYS #xFFFFFFFF)

(cffi:defcfun ("SDL_EnableUNICODE" SDL-Enable-UNICODE) :int
  (enable :int))

(cl:defconstant SDL-DEFAULT-REPEAT-DELAY 500)

(cl:defconstant SDL-DEFAULT-REPEAT-INTERVAL 30)

(cffi:defcfun ("SDL_EnableKeyRepeat" SDL-Enable-Key-Repeat) :int
  (delay :int)
  (interval :int))

(cffi:defcfun ("SDL_GetKeyRepeat" SDL-Get-Key-Repeat) :void
  (delay :pointer)
  (interval :pointer))

(cffi:defcfun ("SDL_GetKeyState" SDL-Get-Key-State) :pointer
  (numkeys :pointer))

(cffi:defcfun ("SDL_GetModState" SDL-Get-Mod-State) :int)

(cffi:defcfun ("SDL_SetModState" SDL-Set-Mod-State) :void
  (modstate :int)) ;Sdl-Mod

(cffi:defcfun ("SDL_GetKeyName" SDL-Get-Key-Name) :string
  (key Sdl-Key))

(defconstant SDL-KEY-MOD-CTRL	(logior  (cffi:foreign-enum-value 'Sdl-Mod :SDL-KEY-MOD-LCTRL)
					 (cffi:foreign-enum-value 'Sdl-Mod :SDL-KEY-MOD-RCTRL)))
(defconstant SDL-KEY-MOD-SHIFT	(logior  (cffi:foreign-enum-value 'Sdl-Mod :SDL-KEY-MOD-LSHIFT)
					 (cffi:foreign-enum-value 'Sdl-Mod :SDL-KEY-MOD-RSHIFT)))
(defconstant SDL-KEY-MOD-ALT	(logior  (cffi:foreign-enum-value 'Sdl-Mod :SDL-KEY-MOD-LALT)
					 (cffi:foreign-enum-value 'Sdl-Mod :SDL-KEY-MOD-RALT)))
(defconstant SDL-KEY-MOD-META	(logior  (cffi:foreign-enum-value 'Sdl-Mod :SDL-KEY-MOD-LMETA)
					 (cffi:foreign-enum-value 'Sdl-Mod :SDL-KEY-MOD-RMETA)))
